-
Notifications
You must be signed in to change notification settings - Fork 103
Don't fail send_all
retaining reserves for 0 channels
#540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Don't fail send_all
retaining reserves for 0 channels
#540
Conversation
Previouly, `OnchainPayment::send_all_to_address` would fail in the `retain_reserves` mode if the maintained reserves were below the dust limit. Most notably this would happen if we had no channels open at all. Here, we fix this by simply falling back to the draining case (not considering reserves) if the anchor reserves are below dust. We also add a unit test that would have caught this regression in the first place.
👋 Thanks for assigning @jkczyz as a reviewer! |
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
.. as this is useful information.
We create temporary transactions for fee estimation purposes. Doing this might advance the descriptor state though. So here we call `cancel_tx` to tell the wallet we no longer intend to broadcast the temporary transactions.
0c027cf
to
1e5f4a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have less context here but this does look like it will fix our issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after squash and any comments to clarify the test expections.
Squashed with the following additional changes: > git diff-tree -U2 1e5f4a27 dc2902af
diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs
index 1d33a14c..fde56620 100644
--- a/tests/integration_tests_rust.rs
+++ b/tests/integration_tests_rust.rs
@@ -530,4 +530,5 @@ fn onchain_send_all_retains_reserve() {
node_a.sync_wallets().unwrap();
node_b.sync_wallets().unwrap();
+ // Check node a sent all and node b received it
assert_eq!(node_a.list_balances().spendable_onchain_balance_sats, 0);
assert!(((premine_amount_sat * 2 - onchain_fee_buffer_sat)..=(premine_amount_sat * 2))
@@ -556,4 +557,5 @@ fn onchain_send_all_retains_reserve() {
expect_channel_ready_event!(node_b, node_a.node_id());
+ // Check node a sent all and node b received it
assert_eq!(node_a.list_balances().spendable_onchain_balance_sats, 0);
assert!(((premine_amount_sat - reserve_amount_sat - onchain_fee_buffer_sat)
@@ -570,4 +572,5 @@ fn onchain_send_all_retains_reserve() {
node_b.sync_wallets().unwrap();
+ // Check node b sent all and node a received it
assert_eq!(node_b.list_balances().total_onchain_balance_sats, reserve_amount_sat);
assert_eq!(node_b.list_balances().spendable_onchain_balance_sats, 0); |
Fixes #539.
Previouly,
OnchainPayment::send_all_to_address
would fail in theretain_reserves
mode if the maintained reserves were below the dustlimit. Most notably this would happen if we had no channels open at all.
Here, we fix this by simply falling back to the draining case (not
considering reserves) if the anchor reserves are below dust. We also add
a unit test that would have caught this regression in the first place.
Note: Github diff really messes up the first commit which is mostly adding an
if
and re-indenting the previous codeblock. It's best reviewed withgit show --color-moved --ignore-all-space